package com.ruoyi.core.service.impl;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.core.domain.vo.ShopUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.core.mapper.ShopUserMapper;
import com.ruoyi.core.domain.ShopUser;
import com.ruoyi.core.service.IShopUserService;
import com.ruoyi.common.core.text.Convert;

/**
 * 网点员工列表Service业务层处理
 * 
 * @author lgc
 * @date 2020-08-08
 */
@Service
public class ShopUserServiceImpl implements IShopUserService 
{
    @Autowired
    private ShopUserMapper shopUserMapper;

    /**
     * 查询网点员工列表
     * 
     * @param shopUserId 网点员工列表ID
     * @return 网点员工列表
     */
    @Override
    public ShopUser selectShopUserById(Long shopUserId)
    {
        return shopUserMapper.selectShopUserById(shopUserId);
    }

    /**
     * 查询网点员工列表列表
     * 
     * @param shopUser 网点员工列表
     * @return 网点员工列表
     */
    @Override
    public List<ShopUser> selectShopUserList(ShopUser shopUser)
    {
        return shopUserMapper.selectShopUserList(shopUser);
    }

    /**
     * 新增网点员工列表
     * 
     * @param
     * @return 结果
     */
    @Override
    public int insertShopUser(Long userId,Long shopId,Long createBy)
    {
        ShopUser su = new ShopUser();
        su.setCreatedBy(createBy);
        su.setCreatedDate(new Date());
        su.setLastUpdatedBy(createBy);
        su.setLastUpdatedDate(Calendar.getInstance().getTime());
        su.setShopId(shopId);
        su.setUserId(userId);
        if (shopUserMapper.insertShopUser(su) == 1)
            return 1;
        throw new BusinessException("插入ShopUser数据异常!");

    }

    /**
     * 修改网点员工列表
     * 
     * @param shopUser 网点员工列表
     * @return 结果
     */
    @Override
    public int updateShopUser(ShopUser shopUser)
    {
        return shopUserMapper.updateShopUser(shopUser);
    }

    /**
     * 删除网点员工列表对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteShopUserByIds(String ids)
    {
        return shopUserMapper.deleteShopUserByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除网点员工列表信息
     * 
     * @param shopUserId 网点员工列表ID
     * @return 结果
     */
    @Override
    public int deleteShopUserById(Long shopUserId)
    {
        return shopUserMapper.deleteShopUserById(shopUserId);
    }

    @Override
    public List<ShopUserVo> selectShopUserVoList(ShopUser shopUser) {
        return shopUserMapper.selectShopUserVoList(shopUser);
    }
}
